﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ValiVIN.Manufacturer
{
    internal class BigDogMotorcycles : IVINManufacturer
    {
        private static readonly int _EarliestYear = 1995;
        //Example VIN: 5j11hbj155w000001

        #region Singleton

        static readonly BigDogMotorcycles _instance = new BigDogMotorcycles();

        public static BigDogMotorcycles Instance
        {
            get { return _instance; }
        }

        #endregion

        private void GetSerialNumber(VINumber vin)
        {
            //12 - 17
            string serialNum = vin.VIN.Substring(11, 6);
            vin.SerialNumber = serialNum;
        }

        private void GetModel(VINumber vin)
        {
            //model for bigdog motorcycles is character 5 (index 4)
            string m = vin.VIN.Substring(4, 1);
            string modelKey = "Model";
            string model = string.Empty;

            switch (m)
            {
                case "A":
                    model = "Vintage Classic";
                    break;
                case "B":
                    model = "ProSport (ProGlide)";
                    break;
                case "C":
                    model = "Coyote";
                    break;
                case "D":
                    model = "Vintage Light";
                    break;
                case "E":
                    model = "AeroGlide";
                    break;
                case "F":
                    model = "AeroSport";
                    break;
                case "G":
                    model = "Bulldog";
                    break;
                case "H":
                    model = "Pitbull";
                    break;
                case "J":
                    model = "Boxer";
                    break;
                case "K":
                    model = "Vintage Sport";
                    break;
                case "L":
                    model = "Husky";
                    break;
                case "M":
                    model = "Mastiff";
                    break;
                case "N":
                    model = "Chopper";
                    break;
                case "P":
                    model = "Wolf";
                    break;
                case "R":
                    model = "Ridgeback";
                    break;
                case "T":
                    model = "Chopper - DT";
                    break;
                case "Z":
                    model = "Custom";
                    break;
            }

            //add to list
            if (!string.IsNullOrEmpty(model))
            {
                vin.ManufacturerSpecifics[modelKey] = model;
            }
        }

        #region IVINManufacturer Members

        public bool Decode(VINumber vin)
        {
            //Adjust the Year. Earliest Year for a BigDog Motorcycle is 1995.
            if (vin.Year1 < _EarliestYear)
            {
                vin.Year1 = vin.Year2;
                vin.Year2 = 0;
            }

            vin.Plant = "Wichita, Kansas";
            GetModel(vin);
            vin.EngineType = "OHV";
            GetSerialNumber(vin);
            //vin.ManufacturerSpecifics["Engine Family"] = "OHV";

            return true;
        }

        public string ManufacturerName(string vin)
        {
            return "Big Dog Motorcycles";
        }

        #endregion
    }
}
